package vn.edu.ptithcm.pim.dao;

import vn.edu.ptithcm.pim.dom.Diploma;

import java.util.List;

import org.hibernate.LockMode;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

@SuppressWarnings("rawtypes")
public class DiplomaDao extends HibernateDaoSupport {

	public void save(Diploma diploma) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().save(diploma);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void saveOrUpdate(Diploma diploma) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().saveOrUpdate(diploma);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void lock(Diploma diploma) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().lock(diploma, LockMode.NONE);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void delete(Diploma diploma) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().delete(diploma);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Diploma merge(Diploma diploma) {
		try {
			return (Diploma) getHibernateTemplate().merge(diploma);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Diploma findById(java.lang.Long id) {
		try {
			return (Diploma) getHibernateTemplate().get(Diploma.class, id);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public List findByExample(Diploma diploma) {
		try {
			return getHibernateTemplate().findByExample("Diploma", diploma);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public List getAll() {
		try {
			return getHibernateTemplate().loadAll(Diploma.class);
		} catch (RuntimeException re) {
			throw re;
		}
	}
}
